package test.wuweiqiang;

import oop5.Cat;

public class ShangChang {
    String scname;
    String address;
    //    String canjinzhi;
//    String tixudao;
//    String chaoguo;
    int count = 0;
    Card[] cards = new Card[10];

    public void show() {
        System.out.println("商场的名称是：" + scname);
        System.out.println("商场的地址是：" + address);
    }

    public boolean add(Card c) {
        cards[count++] = c;
        return true;
    }

    public boolean zhangfen(String num2, int jifen) {
        for (int i = 0; i < count; i++) {
            if (num2.equals(this.cards[i].getCardnumber())) {
                this.cards[i].setScore(this.cards[i].getScore() + jifen);
                return true;
            }
        }
        return false;
    }

    public String duihaun(String no, int choice) {
        for (int i = 0; i < count; i++) {
            if (cards[i].getCardnumber().equals(no)) {
                if (choice == 1) {
                    if (cards[i].getScore() >= 1000) {
                        cards[i].setScore(cards[i].getScore() - 1000);
                        return "砂锅";
                    }
                } else if (choice == 2) {
                    if (cards[i].getScore() >= 400) {
                        cards[i].setScore(cards[i].getScore() - 400);
                        return "剃须刀";
                    }
                } else if (choice == 3) {
                    if (cards[i].getScore() >= 100) {
                        cards[i].setScore(cards[i].getScore() - 100);
                        return "餐巾纸";
                    }
                }
            }
        }
        return null;
    }


}
